<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<script type="text/javascript">
    $(document).ready(function(){
        $('#position_monthlySalary').change(function(){
            //calcUrl = "'" + "<?php echo url_for('position/hourlySalaryUpdate?monthlySalary=') ?>" + $('#position_monthlySalary').val() + "'";
            calcUrl = "<?php echo url_for('position/hourlySalaryUpdate?monthlySalary=') ?>" + $('#position_monthlySalary').val() ;
            $('#ajaxResult').load(calcUrl);

            $.ajax({
                url: calcUrl,
                type: 'GET',
                dataType: 'html',
                timeout: 1000,
                error: function(){
                    alert('Error loading XML document');
                },
                success: function(data){
                    $('input[id^="position_hourlySalary"]').val(data);
                }
            });


            // $('input[id^="position_hourlySalary"]').val('54');

            //           msg ="Monthly Salary Changed " + $('#position_monthlySalary').val();
            //          alert(msg);
        });
    });


</script>
<div id="ajaxResult"></div>
<form id="positionForm" action="<?php echo url_for('position/' . ($form->getObject()->isNew() ? 'create' : 'update') . (!$form->getObject()->isNew() ? '?id=' . $form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
    <?php if (!$form->getObject()->isNew()): ?>
        <input type="hidden" name="sf_method" value="put" />
    <?php endif; ?>
        <table>
            <tfoot>
                <tr>
                    <td colspan="2">
                    <?php echo $form->renderHiddenFields(false) ?>
                    &nbsp;<a href="<?php echo url_for('position/index') ?>">Back to list</a>
                    <?php if (!$form->getObject()->isNew()): ?>
                        &nbsp;<?php echo link_to('Delete', 'position/delete?id=' . $form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
                    <?php endif; ?>
                        <input type="submit" value="Save" />
                    </td>
                </tr>
            </tfoot>
            <tbody>
            <?php echo $form->renderGlobalErrors() ?>
                        <tr>
                            <th><?php echo $form['employee_id']->renderLabel() ?></th>
                            <td>
                    <?php echo $form['employee_id']->renderError() ?>
                    <?php echo $form['employee_id'] ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['name']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['name']->renderError() ?>
                    <?php echo $form['name'] ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['startDate']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['startDate']->renderError() ?>
                    <?php echo $form['startDate'] ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['endDate']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['endDate']->renderError() ?>
                    <?php echo $form['endDate'] ?>
                    </td>
                </tr>
                 <tr>
                    <th>Shifts</th>
                    <td>                      
                       <?php include_partial('shiftSelector', 
                               array('assignments' => $form->getObject()->getShiftAssignment(),
                                   'missingShifts' => $missingShifts)) ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['payment_calculation_type_id']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['payment_calculation_type_id']->renderError() ?>
                    <?php echo $form['payment_calculation_type_id'] ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['wage_type_id']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['wage_type_id']->renderError() ?>
                    <?php echo $form['wage_type_id']->render() ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['salary']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['salary']->renderError() ?>
                    <?php echo $form['salary']->render() ?>
                    </td>
                </tr>
               
                <tr>
                    <th><?php echo $form['payment_periodicity_id']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['payment_periodicity_id']->renderError() ?>
                    <?php echo $form['payment_periodicity_id'] ?>
                    </td>
                </tr>
                <tr>
                    <th><?php echo $form['location_id']->renderLabel() ?></th>
                    <td>
                    <?php echo $form['location_id']->renderError() ?>
                    <?php echo $form['location_id'] ?>
                    </td>
                </tr>
            <?php include_partial('employee/form_stampedData', array('form' => $form)) ?>
        </tbody>
    </table>
</form>
<script type="text/javascript">
    
</script>